//使用mock提供接口数据
import Mock from 'mockjs'
import data from './data.json'
import shops from './shops.json'
Mock.mock('/api/goods',{code:0,data:data.goods})
Mock.mock('/api/ratings',{code:0,data:data.ratings})
Mock.mock('/api/info',{code:0,data:data.info})
//根据请求在id参数返回对应的商家数据
Mock.mock(/^\/api\/shop\/\d+$/,function(options){
    const id=options.url.substring(10)
    console.log("/api/shop",options,shop||shops[0])
    const shop=shops.find(shop=>shop.id==id)
    return Mock.mock({code:0,data:shop||shops[0]})
})